<?php

include("../lib/item.lib");

include("../lib/db.lib");
include("../lib/std.lib");
require("./user_status.php");


$cat_id=param("cat_id");

if(!$cat_id && param("cat_by_date"))
{
        if( preg_match ("/^(\d{4})(\d{0,2})(\d{0,2})/", param("cat_by_date"), $match) ){
		$xys_date=$match;
		$xys_date[0]="Date";
	}
	$cat_id=cat_check($xys_date,1); //no add
}

if(!$cat_id) $cat_id=param("current_cat_id");

if(!$cat_id){
	redirect("","/");
	exit();
}

//echo "cat_id:",$cat_id;

setcookie("current_cat_id",$cat_id,time()+60*60*24*1,"/");


if(!$shop_id) $shop_id=param("shop_id");

$title=cat_all_parent($shop_id,$cat_id,"p_cat_show.php");
$page_title=cat_all_parent($shop_id,$cat_id);
$item_num=cat_get_all_product_num($shop_id,$cat_id);

$verify_code=cat_get_other($shop_id,$cat_id);
$true_code=floor(sin($cat_id*$cat_id)*1000);

if($verify_code){
	$can_append=1;
}

if(param("switch")){
	product_switch_order($cat_id,$id_1,$id_2);
}

$start=param("start");
if($start<=0) $start=1;
$step=100;
$pre_start=$start-$step;

if($pre_start>0){
   $p_str= "<a href=\"p_cat_pd_list.php?start=$pre_start&cat_id=$cat_id\">Previous $step </a>&nbsp;";
}
if($item_num >=$start+$step){
    $next_start=$start+$step;
    $n_str= "<a href=\"p_cat_pd_list.php?start=$next_start&cat_id=$cat_id\">Next $step</a> &nbsp;";
}


$status_str =" ( From $start to ".min($start+$step-1,$item_num).".";
$status_str .=" Total $item_num items) ";

if($cat_id) $list=cat_all_pd_list($shop_id,$cat_id,0);
require("d_show_list.php");
exit();
?>


